package product

import (
	"encoding/json"
	"fmt"
	"os"
)

func GetProduct(string2 string) Products {
	filePtr, err := os.Open(string2)
	if err != nil {
		fmt.Println("文件打开失败 [Err:%s]", err.Error())

	}
	defer filePtr.Close()

	var products Products
	// 创建json解码器
	decoder := json.NewDecoder(filePtr)
	err = decoder.Decode(&products)
	if err != nil {
		fmt.Println("解码失败", err.Error())
	} else {
		//fmt.Println("解码成功")
	}
	return products
}

type Products struct {
	API     string      `json:"api"`
	AppConf interface{} `json:"appConf"`
	Data    struct {
		Data []struct {
			AgentProduct           interface{}   `json:"agentProduct"`
			AuctionStatus          interface{}   `json:"auctionStatus"`
			BarCode                string        `json:"barCode"`
			BdOp                   bool          `json:"bdOp"`
			BrandID                interface{}   `json:"brandId"`
			BrandName              interface{}   `json:"brandName"`
			BusinessFormID         interface{}   `json:"businessFormId"`
			BuyLimitRuleDto        interface{}   `json:"buyLimitRuleDto"`
			BuyLimitRuleFlag       bool          `json:"buyLimitRuleFlag"`
			CateID                 int           `json:"cateId"`
			CateID1                int           `json:"cateId1"`
			CateID2                int           `json:"cateId2"`
			CateName               string        `json:"cateName"`
			CateName1              string        `json:"cateName1"`
			CateName2              string        `json:"cateName2"`
			ChatBuyLightItem       bool          `json:"chatBuyLightItem"`
			Code                   int           `json:"code"`
			CombineItemIDList      []interface{} `json:"combineItemIdList"`
			CombineItemSize        int           `json:"combineItemSize"`
			CombineMainItemIDList  []interface{} `json:"combineMainItemIdList"`
			CombineMainItemSize    int           `json:"combineMainItemSize"`
			CombineMainProductSize interface{}   `json:"combineMainProductSize"`
			CombineProductSize     interface{}   `json:"combineProductSize"`
			CombineSubItemVOList   interface{}   `json:"combineSubItemVOList"`
			CombineSubProductList  interface{}   `json:"combineSubProductList"`
			Control                bool          `json:"control"`
			CustomCategoryID       int           `json:"customCategoryId"`
			CustomCategoryList     []struct {
				Channels                  interface{} `json:"channels"`
				Count                     int         `json:"count"`
				CustomCategoryID          int         `json:"customCategoryId"`
				CustomCategoryName        string      `json:"customCategoryName"`
				CustomCategoryParentID    int         `json:"customCategoryParentId"`
				CustomCategoryParentName  string      `json:"customCategoryParentName"`
				Depth                     int         `json:"depth"`
				EleCustomCategoryID       int64       `json:"eleCustomCategoryId"`
				EleCustomCategoryParentID interface{} `json:"eleCustomCategoryParentId"`
				HasChildren               interface{} `json:"hasChildren"`
				Image                     interface{} `json:"image"`
				ItemRank                  interface{} `json:"itemRank"`
				ItemTop                   interface{} `json:"itemTop"`
				Rank                      int         `json:"rank"`
				ShopCustomID              interface{} `json:"shopCustomId"`
				SmartSort                 interface{} `json:"smartSort"`
				Top                       interface{} `json:"top"`
			} `json:"customCategoryList"`
			CustomCategoryName       string        `json:"customCategoryName"`
			CustomCategoryParentID   interface{}   `json:"customCategoryParentId"`
			CustomCategoryParentName string        `json:"customCategoryParentName"`
			CustomProperties         []interface{} `json:"customProperties"`
			CycleBuyFlag             interface{}   `json:"cycleBuyFlag"`
			Description              string        `json:"description"`
			DraftID                  interface{}   `json:"draftId"`
			DurationSaleDto          interface{}   `json:"durationSaleDto"`
			DurationSaleFlag         bool          `json:"durationSaleFlag"`
			EditSource               interface{}   `json:"editSource"`
			EducatePreferential      interface{}   `json:"educatePreferential"`
			EleID                    string        `json:"eleId"`
			EleProductID             interface{}   `json:"eleProductId"`
			EleSkuID                 interface{}   `json:"eleSkuId"`
			ExistedQuantity          interface{}   `json:"existedQuantity"`
			ForbidEndTime            interface{}   `json:"forbidEndTime"`
			ForbidSale               bool          `json:"forbidSale"`
			ForbidSaleReason         interface{}   `json:"forbidSaleReason"`
			ForbidSaleReasonDesc     interface{}   `json:"forbidSaleReasonDesc"`
			ForbidSaleReasonSummary  interface{}   `json:"forbidSaleReasonSummary"`
			HasCombineSubItem        bool          `json:"hasCombineSubItem"`
			HasSku                   bool          `json:"hasSku"`
			Images                   []struct {
				IsMaster    bool        `json:"isMaster"`
				LevelSource interface{} `json:"levelSource"`
				URL         string      `json:"url"`
			} `json:"images"`
			IncludeStoreCateInfo bool        `json:"includeStoreCateInfo"`
			IndustryCustomStruct interface{} `json:"industryCustomStruct"`
			InvokeID             interface{} `json:"invokeId"`
			IsJoinActivity       bool        `json:"isJoinActivity"`
			IsProcessing         bool        `json:"isProcessing"`
			IsWeight             bool        `json:"isWeight"`
			ItemCanSell          bool        `json:"itemCanSell"`
			ItemCateRelationship bool        `json:"itemCateRelationship"`
			ItemID               int64       `json:"itemId"`
			ItemPropValues       interface{} `json:"itemPropValues"`
			ItemSkuList          interface{} `json:"itemSkuList"`
			ItemWeight           int         `json:"itemWeight"`
			MinActivePrice       float64     `json:"minActivePrice"`
			MonthlySaledQuantity int         `json:"monthlySaledQuantity"`
			OriginalSaleUnit     interface{} `json:"originalSaleUnit"`
			OutID                string      `json:"outId"`
			PackageFeeDto        interface{} `json:"packageFeeDto"`
			PackageFlag          bool        `json:"packageFlag"`
			PicURL               string      `json:"picUrl"`
			PreMinusWeight       interface{} `json:"preMinusWeight"`
			PreSaleDto           struct {
				EndDate            interface{} `json:"endDate"`
				EndDeliveryDate    interface{} `json:"endDeliveryDate"`
				LatestDeliveryDate interface{} `json:"latestDeliveryDate"`
				PreSaleType        interface{} `json:"preSaleType"`
				StartDate          interface{} `json:"startDate"`
				StartDeliveryDate  interface{} `json:"startDeliveryDate"`
			} `json:"preSaleDto"`
			PreSaleFlag               interface{}   `json:"preSaleFlag"`
			PreparationTime           interface{}   `json:"preparationTime"`
			Price                     float64       `json:"price"`
			Processing                []interface{} `json:"processing"`
			ProductID                 string        `json:"productId"`
			ProductSkuList            interface{}   `json:"productSkuList"`
			PurchaseQuantity          float64       `json:"purchaseQuantity"`
			Quantity                  float64       `json:"quantity"`
			QuantityPartZero          interface{}   `json:"quantityPartZero"`
			Rank                      interface{}   `json:"rank"`
			SaleUnit                  interface{}   `json:"saleUnit"`
			ScItemID                  interface{}   `json:"scItemId"`
			SceneType                 interface{}   `json:"sceneType"`
			SellerID                  int64         `json:"sellerId"`
			SevenDaysWithOutReason    interface{}   `json:"sevenDaysWithOutReason"`
			ShelvesNum                interface{}   `json:"shelvesNum"`
			ShopName                  string        `json:"shopName"`
			SkuMaxPrice               interface{}   `json:"skuMaxPrice"`
			SkuMaxQuantity            interface{}   `json:"skuMaxQuantity"`
			SkuMinPrice               interface{}   `json:"skuMinPrice"`
			SkuMinQuantity            interface{}   `json:"skuMinQuantity"`
			SoldOutSoon               interface{}   `json:"soldOutSoon"`
			SpuBarCode                interface{}   `json:"spuBarCode"`
			SpuID                     int           `json:"spuId"`
			SpuStatus                 interface{}   `json:"spuStatus"`
			SpuTitle                  interface{}   `json:"spuTitle"`
			Status                    int           `json:"status"`
			StepQuantity              interface{}   `json:"stepQuantity"`
			StockUnit                 string        `json:"stockUnit"`
			StoreCateID               interface{}   `json:"storeCateId"`
			StoreID                   int           `json:"storeId"`
			StoreRule                 interface{}   `json:"storeRule"`
			SubTitle                  interface{}   `json:"subTitle"`
			SupplyRelationshipDTOList interface{}   `json:"supplyRelationshipDTOList"`
			SyncCustomCateToItem      interface{}   `json:"syncCustomCateToItem"`
			SyncItemOption            interface{}   `json:"syncItemOption"`
			Title                     string        `json:"title"`
			VideoDTOList              interface{}   `json:"videoDTOList"`
			WeightType                interface{}   `json:"weightType"`
			Wid                       string        `json:"wid"`
		} `json:"data"`
		ErrCode    string `json:"errCode"`
		ErrMessage string `json:"errMessage"`
		Total      int    `json:"total"`
	} `json:"data"`
	Ret []string `json:"ret"`
	V   string   `json:"v"`
}
